package org.wattdepot.simulation.uhcampus.main;

import it.sauronsoftware.cron4j.Scheduler;
import it.sauronsoftware.cron4j.Task;

/**
 * The main program for the UH Campus simulation.
 * @author Philip Johnson
 */
public class Simulation {
  
    /**
     * The main for the UH Campus simulation. 
     * @param args Ignored.
     * @throws Exception If problems occur.
     */
    public static void main(String[] args) throws Exception {
      String schedule = "*/20 * * * *";
      Scheduler s = new Scheduler();
      Task task = new SimulationTask();
      s.schedule(schedule, task);
      try {
        s.start();
        System.out.println("UH Campus simulation is now running. Press return to stop server.");
        while (System.in.available() == 0) {
          Thread.sleep(2000);
        }
        System.out.println("Stopping UH Campus simulation.");
        s.stop();
      }
      catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
      }
    }
  }
